package mail.fetch.m21cn;

import mail.entity.ProxyEntity;
import mail.util.FileManager;

import java.net.CookieManager;
import java.nio.charset.Charset;
import java.util.List;

/**
 * @author: Hanjiafeng
 * @date: Created in 16:12 2019/3/13
 * @desc:
 */
public class Mail21cnEntrance {

    public static void main(String... args) throws Exception {
        Mail21cnEntrance entrance = new Mail21cnEntrance();
        entrance.t1();
    }

    public void t1() throws Exception {
        ProxyEntity proxyEntity = new ProxyEntity(null, "localhost", 8888, "", "");
        Login11 login11 = new Login11(proxyEntity);
        CookieManager cookieManager = login11.getCookieManager("tianlangqiqing@21cn.com", "huifenghechang1.");
        Inbox11 inbox11 = new Inbox11(cookieManager, proxyEntity);
        List<Mail21cnEntity> entityList = inbox11.getMailListDuringHalfYear();
        for (Mail21cnEntity entity : entityList) {
            FileManager.overwrite("F:\\Mail21cnCreditBill\\" + System.currentTimeMillis() + ".html", entity.getContent()
                    , Charset.forName("gb2312"));
            try {
                Thread.sleep(10);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
